package com.xbb.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xbb.entity.Student;
import com.xbb.entity.dto.StudentDto;
import com.xbb.service.StudentService;
import com.xbb.util.Result;

@RestController
public class StudentController {

	@Autowired
	private StudentService studentService;
	
	
	@RequestMapping("/getStuList")
	public Object getStuList(StudentDto studentDto,ModelMap map) {
		List<StudentDto> list = studentService.getStus(studentDto);
		studentDto.setLimit(null);
		studentDto.setPage(null);
		List<StudentDto> list2 = studentService.getStus(studentDto);
		return new Result(0,"",list2.size(),list);
	}
	
	@RequestMapping("/addStu")
	public Object addStu(Student student) {
		if(studentService.addStu(student)) {
			return new Result(0,"添加成功");
		}else {
			return new Result(1,"添加失败");
		}
	}
	
	
	@RequestMapping("/updateStu")
	public Object updateStu(Student student) {
		if(studentService.updateStu(student)) {
			return new Result(0,"修改成功");
		}else {
			return new Result(1,"修改失败");
		}
	}
	
	@RequestMapping("/delStu")
	public Object delStu(int stuid) {
		if(studentService.delStu(stuid)) {
			return new Result(0,"删除成功");
		}else {
			return new Result(1,"删除失败");
		}
	}
	


	
}
